﻿var left_condition = "";
function fnSearch(o) {
    var key = window.document.getElementById("keyword").value;
    var requestStr = "entity=V_SetTableList&condition=" + encodeURI("TableName='" + const_LeftTable + "' ") + "&output=json&r=" + Math.random() + "&customCondition=Caption like '%"+encodeURI(key)+"%'";
    //_myDataTable.requery(requestStr);
}

//初始化左边菜单
function InitLeftData() {
   // debugger
    $.get("/Extend/AjaxData/DataTableJsonList.aspx?entity=" + const_LeftTable + "&type=0",
            function (d, t) {
                //alert(d); 
                var data = eval("(" + d + ")");
                var _temp = [];
                $.each(data.rows, function (e) {
                    _temp.push($.extend(data.rows[e], { drag: true }));
                });
                $.fn.zTree.init($("#_LeftTree"), setting, _temp);

            });
}

/* 树 */
var setting = {
    edit: {
        drag: {
            autoExpandTrigger: true
        },
        enable: true,
        showRemoveBtn: false,
        showRenameBtn: false,
        editNameSelectAll: false

    },
    data: {
        key: {
            title: "t"
        },
        simpleData: {
            enable: true
        }
    },
    callback: {
        onClick: ItemOnClick
    }
};

//树点击事件
var _treeNode = null;
function ItemOnClick(event, treeId, treeNode, clickFlag) {
    _treeNode = treeNode;
    if (typeof (custItemOnClick) == "function") {
        //用于支持客户自定义脚本
        custItemOnClick(event, treeId, treeNode, clickFlag);
        return;
    }

    const_CustomCondition = const_ForeignKey + window.decodeURI("='" + _treeNode.id + "'");
    initialRequestUrl = "pageindex=1&entity=" + const_entityName + "&order=" + const_Order + "&r=" + Math.random() + "&zip=94089&results=10&output=json&functionid=" + const_functionId + "&customCondition=" + (const_CustomCondition),
    BindData();
    GetTotal("AjaxData/DataTableJsonList.aspx?onlyTotal=true&" + initialRequestUrl);
}

//增加新节点
function AddNewNode(id, name) {
    var zTree = $.fn.zTree.getZTreeObj("_LeftTree");
    zTree.addNodes(_treeNode, { id: id, pId: _treeNode.id, name: name });
}

